using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace HappyFrogXna.Miscellaneous
{
    public static class GameMathHelper
    {
        public static double DistanceOfPos(Vector2 pos1, Vector2 pos2)
        {
            return Math.Sqrt(Math.Pow(pos1.X - pos2.X, 2) + Math.Pow(pos1.Y - pos2.Y, 2));
        }

        public static Vector2 CrossPositionOfACircleAndALinePassCircleCenter(Vector2 circleCenter, float radius, Vector2 aPosAtline)
        {
            float deltaX = (aPosAtline.X - circleCenter.X) * radius / (float)DistanceOfPos(circleCenter, aPosAtline);
            float deltaY = (aPosAtline.Y - circleCenter.Y) * radius / (float)DistanceOfPos(circleCenter, aPosAtline);
            return new Vector2(circleCenter.X + deltaX, circleCenter.Y + deltaY);
        }
    }
}
